package com.yyt.module_main.home;

import android.graphics.Color;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.roughike.bottombar.OnTabSelectListener;
import com.yyt.libsrc.router.RouteTable;
import com.yyt.module_main.R;
import com.yyt.module_main.databinding.ActivityMainBinding;

import top.lixb.libcommon.base.BaseActivity;
import top.lixb.libcommon.base.ViewPagerAdapter;

@Route(path = RouteTable.main_home)
public class MainActivity extends BaseActivity<ActivityMainBinding> {

    private ViewPagerAdapter mPagerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setNoTitle();

        init();

    }

    private void init() {
        FragmentManager fm = getSupportFragmentManager();
        mPagerAdapter = new ViewPagerAdapter(fm);
        mPagerAdapter.addFragment(new HomeFragment(),"首页");
        mPagerAdapter.addFragment(new CollectFragment(),"收款");
        mPagerAdapter.addFragment(new MineFragment(),"我的");
        mContentBinding.vp.setAdapter(mPagerAdapter);


        mContentBinding.bottomNavigation.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelected(int tabId) {
                if (tabId == R.id.tab_0) {
                    mContentBinding.vp.setCurrentItem(0);
                } else if (tabId == R.id.tab_1) {
                    mContentBinding.vp.setCurrentItem(1);
                    setStatusbarBackgroundColor(Color.rgb(0x43,0x8d,0xff));
                } else if (tabId == R.id.tab_2) {
                    mContentBinding.vp.setCurrentItem(2);
//                    #FC934D 100%
                    setStatusbarBackgroundColor(Color.rgb(0xfc,0x93,0x4d));
                }
            }
        });
    }
}
